import { createRouter, createWebHashHistory } from 'vue-router'

// 发现页的路由
const discover = [{
  path: '',
  redirect: '/discover',
  children: [
    {
      path: '/discover',
      name: 'discover',
      component: () => import('@/views/Discover/DiscoverPage.vue'),
      meta: {
        hideTabBar: false
      }
    },
    {
      path: '/search',
      name: 'search',
      component: () => import('@/views/Search/Search.vue'),
      meta: {
        hideTabBar: true
      }
    }
  ]
}
]

const music = [{
  path: '',
  redirect: '/music',
  children: [{
    path: '/music',
    name: 'music',
    component: () => import('@/views/Music/MusicPage.vue'),
    meta: {
      hideTabBar: false
    },
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/Search/Search.vue'),
    meta: {
      hideTabBar: true
    }
  },
  {
    path: '/repay',
    name: 'repay',
    component: () => import('@/views/Repay/Repay.vue'),
    meta: {
      hideTabBar: true
    }
  }
  ]
}
]

const mine = [{
  path: '/',
  redirect: '/mine',
  children: [{
    path: '/mine',
    name: 'mine',
    component: () => import('@/views/Mine/MinePage.vue'),
    meta: {
      hideTabBar: false
    },
  },{
    path: '/message',
    name: 'message',
    component: () => import('@/views/Message/Message.vue'),
    meta: {
      hideTabBar: true
    },
  },{
    path: '/setter',
    name: 'setter',
    component: () => import('@/views/Setter/SetterPage.vue'),
    meta: {
      hideTabBar: true
    },
  }
]}]

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [{
    path: '/',
    component: () => import('@/views/index.vue'),
    redirect: '/music',// 使用重定向，把'/'音质'/music'
    children: [// 配置子路由
      ...discover,
      ...music,
      ...mine,
    ]
  }
  ]
})

router.beforeEach((to, from, next) => {
  // 根据需要控制底部 TabBar 的显示状态
  if (to.meta.hideTabBar) {
    // 如果路由配置了 hideTabBar，则隐藏
    //showTabBar.value = false
  } else {
    // 否则显示
    //showTabBar.value = true
  }

  next()
})


export default router
